package com.banmoon.algorithm.leetcode;

import java.util.ArrayList;
import java.util.List;

public class Question1447 {

    public static void main(String[] args) {
        List<String> list = simplifiedFractions(4);
        System.out.println(list);
    }

    public static List<String> simplifiedFractions(int n) {
        List<String> resultList = new ArrayList<>();
        // 分母
        for (int i = 1; i <= n; i++) {
            // 分子
            for (int j = 1; j < i; j++) {
                if(j==1){
                    resultList.add(j + "/" + i);
                    continue;
                }
                // 判断
                boolean commonDivisor = false;
                LoopA: for (int k = 2; k <= j; k++) {
                    commonDivisor = j%k==0 && i%k==0;
                    if(commonDivisor)
                        break LoopA;
                }
                if(!commonDivisor){
                    resultList.add(j + "/" + i);
                }
            }
        }
        return resultList;
    }

}
